#include <cassert>
#include "../include/json_reader.hpp"

namespace alexcr4ckpentest
{
  JsonReader::JsonReader() noexcept {}
  JsonReader::JsonReader(const std::string& filename) : m_filename{filename} {}

  void JsonReader::set_filename(const std::string& new_filename)
  { m_filename = new_filename; }

  nlohmann::json JsonReader::read()
  {
    nlohmann::json json_obj;
    m_in_file_stream.open(m_filename);

    assert(m_in_file_stream.is_open());

    m_in_file_stream >> json_obj;
    m_in_file_stream.close();

    assert(!json_obj.is_null() && "No json data!");

    return json_obj;
  }
} // namespace alex
